<?php
namespace app\controllers;
use yii\web\Controller;
use Yii;
use app\models\User;
class MemberController extends Controller{

/**
 * 前台会员登陆
 */
	public function actionAuth(){
		$this->layout = 'layout2';
        $model = new User;
        if(Yii::$app->request->isPost){
            $post=Yii::$app->request->post();
//            print_r($post);die;
            if($model->login($post)){
                $this->redirect(['index/index']);
                Yii::$app->end();
            }
        }
		return $this->render('auth',['model' => $model]);
	}

/**
 * 前台会员注册
 */
    public function actionReg(){
        $model = new User;
        $post = Yii::$app->request->post();
        if($model->regByMail($post)){
            Yii::$app->session->setFlash('info','电子邮件已经发送,请注意查收！');
        }
        $this->layout='layout2';
        return $this->render('auth',['model'=>$model]);
    }

/**
 * 会员退出
 */
    public function actionLogout(){
        Yii::$app->session->remove('user');
        if(!isset(Yii::$app->session['user'])){
            $this->redirect(['member/auth']);
        }
    }



}

 ?>